#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void transmit_file(const char *file_1,const char *file_2,const char *file_3);

int main()
{
    const char *filename_1="file_1.txt";
    const char *filename_2="file_2.txt";
    const char *filename_3="file_3.txt";
    transmit_file(filename_1,filename_2,filename_3);
    return 0;
}


void transmit_file(const char *file_1,const char *file_2,const char *file_3)
{
    FILE *fp1 = fopen(file_1,"w");
    FILE *fp2 = fopen(file_2,"r");
    FILE *fp3 = fopen(file_3,"r");

    if(fp1==NULL||fp2==NULL||fp3==NULL)
    {
        printf("无法打开某个文件\n");
        return ;
    }
    char buffer[1024];

    //将file_2清空写入file_1
    while (fgets(buffer, sizeof(buffer), fp2) != NULL)
    {
        fputs(buffer, fp1);
    }

    // 将file_3追加写入file_1
    while (fgets(buffer, sizeof(buffer), fp3) != NULL)
    {
        fputs(buffer, fp1);
    }
    fclose(fp1);
    fclose(fp2);
    fclose(fp3);
}